<template>
  <div class="yard">
    <div class="c-new">
      <div class="c-item">
        <div class="item-head">
          <!-- <img src="../../assets/job/2.png" alt=""> -->
          <div class="head-txt">站院动态</div>
        </div>
        <div class="item-moree" @click="to('/yardnews?yardId='+id)">
          >> 查看更多
        </div>
      </div>
      <div class="item-content">
        <div class="c-img c-img2">
          <img :src="bannerList?.[0]?.bannerUrl" alt="">
          <div class="c-txt o">{{ bannerList?.[0]?.title }}</div>
        </div>
        <div class="new-info">
          <div class="info-item" v-for="item in works" @click="todetail('/yardnewsDetail',item.workId, 'job')">
            <div class="info-i-t">
              <div class="i-l">{{ item.workTitle }}</div>
              <div class="i-r">
                {{ item.createdTime?.slice?.(0,11) }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 专家风采 -->
    <div class="c-new zjfx">
      <div class="zjcitem zjc-1">
        <div class="c-item">
          <div class="item-head">
            <div class="head-txt">专家风采</div>
          </div>
          <div class="item-moree" @click="to('/yardspecialist?yardId='+id)">
            >> 查看更多
          </div>
        </div>
        <div class="item-content" >
          <div class="c-img22" v-if="fengcais?.length">
            <img class="fcimg" :src="fengcais?.[0]?.photo" alt="">
            <div class="c-txt">
              <div class="t">{{ fengcais?.[0]?.name }}</div>
              <div>{{ fengcais?.[0]?.title }}</div>
              <div class="o">{{ fengcais?.[0]?.intro }}</div>
            </div>
          </div>
            <!-- <div class="no">
              暂无数据
            </div> -->
        </div>
      </div>
      <div class="zjcitem zjc-2">
        <div class="c-item">
        <div class="item-head">
          <div class="head-txt">驻站学生</div>
        </div>
        <div class="item-moree" @click="to('/yardstudeng?yardId='+id)">
          >> 查看更多
        </div>
      </div>
      <div class="item-content">
        <div class="new1-info">
          <div class="info-item cp" v-for="item in graduate" @click="todetail2(item.postgraduateId)">
            <img :src="item.photo || '//xiaoyuan-1309318813.cos.ap-beijing.myqcloud.com/pic_202434878.jpg'" alt="">
            <div class="txt">{{ item.name }}</div>
          </div>
        </div>
      </div>
      </div>
    </div>

    <!-- 日志 -->
    <div class="c-notice">
      <div class="c-item">
        <div class="item-head">
          <div class="head-txt">站院日志</div>
        </div>
        <div class="item-moree" @click="to('/yardlogsmore?yardId='+id)">
          >> 查看更多
        </div>
      </div>
      <div class="notice-content">
        <div class='content-item' v-for="item in yardLogs" @click="todetail4(item.logId, 'yardlog')">
          <div class="item-l o cp">
            {{ item.logTitle }}
          </div>
          <div class="item-r">
            {{ item.createdTime?.slice?.(0,11) }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
  import { computed, ref } from 'vue';
  import { useRouter } from 'vue-router';
  import { pageBanner, pageBulletin, pagePoliciesRegulations, pageWorkState, pageCourtyard, pageProfessor, pageCourtyardLog, pageCourtyardMien, getCityMap, pageProfessorMien, listPostgraduate } from '@/api/home';

  const router = useRouter();

  const id = computed(() => router?.currentRoute?.value?.query.yardId)
  // const type = router?.currentRoute?.value?.query.type;

  // console.log('00router', router, id, type)
  const to = (path) => {
    router.push(path)
  }
  const todetail = (path,id1, type) => {
    to(`${path}/${id1}?yardId=${id.value}&type=${type}`)
  }

  const todetail2 = (id1) => {
    to(`/yardstudengdetai/${id1}?yardId=${id.value}`)
  }
    const todetail4 = (id, type) => {
    router.push(`/yardLogDetail/${id}?type=${type}&yardId=${id}`)
  }
  const goDetail3 = (id) => {
    // router.push(`/yardnewsDetail/${id}?type=bulletin&yardId=${id}`)
    router.push(`/yardnotic/${id}?type=bulletin&yardId=${id}`)
  }

  const goDetail5 = (id) => {
    // router.push(`/yardnewsDetail/${id}?type=bulletin&yardId=${id}`)
    router.push(`/yardlogsmore/${id}?type=bulletin&yardId=${id}`)
  }


    // 轮播图
    const bannerList = ref([]);
  const getPageBanners = async() => {
    const params = {
      params: {
        status: true,
        courtyardId: id.value

      },
      page: {
        pageSize: 1,
        pageNum: 1,
      }
    }
    const ret = await pageBanner(params)
    bannerList.value = ret?.data?.list || [];
  }
  getPageBanners();

    // 新闻动态
    const works = ref([]);
  const getPageWorkState = async() => {
    const params = {
      params: {
        status: true,
        courtyardId: id.value
      },
      page: {
        pageSize: 10,
        pageNum: 1,
      }
    }
    const ret = await pageWorkState(params)
    works.value = ret?.data?.list || [];
  }
  getPageWorkState()



  // 专家风采
  const fengcais = ref([]);
  const getPageCourtyardMien =  async() => {
    const params = {
      params: {
        status: true,
        courtyardId: id.value
      },
      page: {
        pageSize: 4,
        pageNum: 1,
      }
    }
    const ret = await pageProfessorMien(params)
    console.log('fengcais', ret)
  
    fengcais.value = ret?.data?.list || [];
  }
  getPageCourtyardMien();



  // 研究生
  const graduate = ref([]);
  const getPagegraduates =  async() => {
    const params = {
      params: {
        status: true,
        courtyardId: id.value
      },
      page: {
        pageSize: 4,
        pageNum: 1,
      }
    }
    const ret = await listPostgraduate(params)
    graduate.value = ret?.data?.list || [];
  }
  getPagegraduates();



  // 通知公告
  const notices = ref([]);
  const getPageBulletin = async() => {
    const params = {
      params: {
        status: true,
        courtyardId: id.value
      },
      page: {
        pageSize: 10,
        pageNum: 1,
      }
    }
    const ret = await pageBulletin(params)
    notices.value = ret?.data?.list || [];
  }
  getPageBulletin();


    // 站院日志
  const yardLogs = ref([]);
  const getPageyardLogs =  async() => {
    const params = {
      params: {
        status: true,
        courtyardId: id.value

      },
      page: {
        pageSize: 5,
        pageNum: 1,
      }
    }
    const ret = await pageCourtyardLog(params)
    yardLogs.value = ret?.data?.list || [];
  }
  getPageyardLogs();





</script>
<style lang="scss" scoped>
.yard {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  color: #777;
  padding: 0 10%;
  background: url(../../assets/xiaoyuan/4.jpeg) no-repeat center center / cover;
  min-height: 1000px;
  padding-bottom: 60px;
  .c-item {
    padding-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .item-head {
      width: 100%;
      display: flex;
      align-items: center;
      color: #666;
      padding-bottom: 20px;
      padding-top: 30px;
      .head-txt {
        font-size: 50px;
        font-weight: bolder;
        color: #000;
      }
    }
    .item-moree {
      color: #068043;
      font-size: 24px;
      font-weight: normal;
      display: flex;
      flex-shrink: 0;
      cursor: pointer;
    }
  }
  .item-content {
    display: flex;
    margin-bottom: 20px;
    height: 630px;

    .c-img {
      position: relative;
      img {
        height: 630px;
        min-width: 980px;
      }
      .c-txt {
        position: absolute;
        bottom: 0;
        left: 0;
        height: 50px;
        width: 100%;
        background: rgba(0,0,0,0.4);
        color: #fff;
        display: flex;
        align-items: center;
        padding-left: 20px;
        font-size: 18px;
      }
    }
    .c-img2 {
      height: 100%;//16 10
      img {
        height: 100%;
        object-fit: contain;
      }
    }
    .new-info {
      flex: 1;
      margin-left: 30px;
      background-color: #fff;
      padding: 15px 30px;
      overflow: hidden;
      color: #777;
      .info-item {
        border-bottom: 2px solid #e5e5e5;
        cursor: pointer;
        &:last-child{
          border-bottom: 0 none;
        }
      }
      .info-i-t {
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 15px 0;
        .i-l {
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          flex: 1;
          overflow: hidden;

        }
        .i-r {
          width: 150px;
          text-align: right;
        }
      }
    }
  }
  .zjfx {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    .zjc-1 {
      flex: 1;
      overflow: hidden;
      margin-right: 40px;
      display: flex;
      flex-direction: column;

      .item-content {
        flex: 1;
        margin-bottom: 0;
        font-size: 0;
        .c-img22 {
          position: relative;
          overflow: hidden;
          width: 1360px;
          display: block;
        }
        .fcimg {
            width: 100%;
          }
        .c-txt {
          width: 50%;
          height: 120px;
          background-color: rgba(240, 240, 201, 0.8);
          bottom: 20px;
          left: 0;
          display: flex;
          flex-direction: column;
          align-items: flex-start;
          justify-content: center;
          padding-left: 30px;
          font-size: 18px;
          color: #068043;
          line-height: 28px;
          position: absolute;
          z-index: 111;
          .t {
            font-size: 28px;
          }
          >div {
            width: 100%;
            overflow: hidden;
          }
        }
      }
    }
    .zjc-2 {
      width: 580px;
      overflow: hidden;
      .item-content {
        height: 460px;
        overflow: hidden;
        .new1-info {
          width: 100%;
          height: 100%;
          display: flex;
          flex-wrap: wrap;
          // justify-content: space-between;
          .info-item {
            flex-shrink: 0;
            width: 168px;
            height: 216px;
            margin-bottom: 30px;
            position: relative;
            margin-right: 20px;
            img {
              width: 100%;
              height: 100%;
              object-fit: contain;
            }
            &:nth-of-type(n+4) {
              margin-bottom: 0;
            }
            .txt {
              position: absolute;
              left: 0;
              bottom: 0;
              height: 50px;
              background-color: #068043;
              color: #fff;
              display: flex;
              align-items: center;
              justify-content: center;
              font-size: 22px;
              width: 100%;
              // font-weight: bold;
            }
          }
        }
      }
    }
  }
  .c-notice {
    .notice-content {
      padding: 10px 30px;
      margin-top: 5px;
      background-color: #fff;
      .content-item {
        border-bottom: 2px solid #e5e5e5;
        font-size: 22px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 0;
        &:last-child{
          border-bottom: 0 none;
        }
        .item-l {
          flex: 1;
          overflow: hidden;
        }
        .item-r {
          width: 150px;
          text-align: right;
        }
      }
    }
  }
}
</style>